package com.sanalkitaplik.resources;

import javax.faces.event.ActionEvent;

import com.sanalkitaplik.usermanagement.UserBookManager;

public class Book extends AbstractBook {
	
	private UserBookManager parent;
	private String tmpAuthor;
	
	public Book() {
		this.parent = null;
		this.tmpAuthor = "";
	}
	
	public void setParent(UserBookManager parent) {
		this.parent = parent;
	}
	
	public boolean getAuthorListEmpty() {
		return this.authorList.isEmpty();
	}
	
	public void setTmpAuthor(String tmpAuthor) {
		this.tmpAuthor = tmpAuthor;
	}
	
	public String getTmpAuthor() {
		return this.tmpAuthor;
	}
	
	public void remove(ActionEvent event) {
		if (parent != null)
			parent.removeBook(this);
	}
	
	public void requestEdit(ActionEvent event) {
		if (parent != null)
			parent.editBookActivate(this);
	}
	
	public void addAuthorListener(ActionEvent event) {
		addAuthor(tmpAuthor);
		tmpAuthor = "";
	}

}
